/**
 * Created by sean on 15-7-20.
 */
function findTrmbTop() {
    if (!self.trmbTop) {
        trmbTop = self;
        try {
            if (parent.trmbTop) {
                trmbTop = parent.trmbTop;
            } else if (parent.parent.trmbTop) {
                trmbTop = parent.parent.trmbTop;
            } else {}
        } catch(e) {}
    }
}
findTrmbTop();
if (trmbTop.miniBrowser != undefined) miniBrowser = trmbTop.miniBrowser;
else miniBrowser = false;
var langXMLLoaded = null;
var langXMLDoc = null;
var langLoaded = null;
var langstrings = null;
var OptionXMLDoc = null;
var RootLocation = '';
function cookieEnabled() {
    return (navigator.cookieEnabled) ? true: false;
}
function Cookie() {
    this.get = function(name) {
        var r = new RegExp('\\b' + name + '=([^;]*)\\b');
        var c = document.cookie + ' ';
        var value = c.match(r);
        return (value == null) ? null: unescape(value[1]);
    };
    this.set = function(name, value) {
        var new_cookie;
        new_cookie = name + "=" + escape(value);
        var nextYear = new Date();
        nextYear.setFullYear(nextYear.getFullYear() + 1);
        new_cookie += "; expires=" + nextYear.toGMTString();
        new_cookie += "; path=/";
        document.cookie = new_cookie;
    };
}
var cookie = new Cookie();
function initializeLanguage() {
    trmbTop.language = cookie.get('lang');
    if (trmbTop.language == null) {
        trmbTop.language = trmbTop.sysData.defaultLanguage;
        if (!trmbTop.language) trmbTop.language = 'en';
    }
    if (trmbTop.rxBrand == 6 && (trmbTop.language != "en") && (trmbTop.language != "ru")) trmbTop.language = "ru";
    if (trmbTop.optionData.removeLangSupport == 'TRUE') trmbTop.language = "en";
    cookie.set("lang", trmbTop.language);
}
function topUrlPath(subPath) {
    var path = trmbTop.document.location.pathname;
    if (path.search('CACHEDIR') == -1) path = path.replace(/[\w.]*$/, '');
    else path = path.replace(/CACHEDIR.*$/, '');
    path = path.replace(/\/xml\/$/, '/');
    path = path.replace(/\/forms\/$/, '/');
    if (subPath) path += subPath;
    return path;
}
function cacheDirPath(subPath) {
    var path = topUrlPath(trmbTop.sysData.cachedir + '/');
    if (subPath) path += subPath;
    return path;
}
function imagePath(file) {
    return cacheDirPath('images/' + file);
}
function getBrandedCss() {
    trmbTop.sunStateMode = 'day';
    if (trmbTop.optionData.OptFugroWebUI == 'TRUE') {
        if ((trmbTop.sunStateMode = (new Cookie()).get('sunStateMode')) == null) trmbTop.sunStateMode = 'auto';
    }
    document.writeln('<link rel="stylesheet" href="' + cacheDirPath('trimble.css') + '" type="text/css"/>');
    var cssName;
    var css2Name;
    switch (trmbTop.rxBrand) {
        default:
        case 0:
        case 10:
            return;
        case 2:
        case 1:
        case 3:
        case 4:
        case 5:
        case 8:
        case 9:
            cssName = 'fugro.css';
            if (trmbTop.optionData.OptFugroWebUI == 'TRUE') {
                if (trmbTop.sunStateMode != 'auto') trmbTop.brightness = trmbTop.sunStateMode;
                if (trmbTop.brightness == 'dusk') css2Name = 'fugroDusk.css';
                if (trmbTop.brightness == 'night') css2Name = 'fugroNight.css';
            }
            break;
        case 6:
            cssName = 'ursus.css';
            break;
        case 7:
            cssName = 'cat.css';
            break;
    }
    document.writeln('<link rel="stylesheet" href="' + cacheDirPath(cssName) + '" type="text/css"/>');
    if (css2Name) document.writeln('<link rel="stylesheet" href="' + cacheDirPath(css2Name) + '" type="text/css"/>');
    if (trmbTop.rxBrand == 6) {
        trmbTop.jQuery('meta[name=copyright]').add('meta[name=description]').add('meta[name=keywords]').remove();
    }
}
function GetHelpLocation() {
    return trmbTop.sysData.HelpLink;
}
function GetHelpProtocol() {
    return trmbTop.sysData.HelpProtocol;
}
function isMiniBrowser() {
    return trmbTop.miniBrowser;
}
function GetStringRoot(lang) {
    if (langXMLLoaded != lang) {
        console.log(433);
        langXMLDoc = getXML(cacheDirPath("xml/" + lang + "_strings.xml"));

        langXMLLoaded = lang;
    }
    return langXMLDoc;
}
function ClearOptionRoot() {
    delete trmbTop.optionData;
    OptionXMLDoc = null;
}
function getSysData(force) {
    if (!trmbTop.sysData || !trmbTop.optionData || force) {
        var url = topUrlPath("xml/dynamic/merge.xml?sysData=&options=");
        var brand = trmbTop.document.location.search.match(/brand=(\d+)/);
        if (brand) url += '&' + brand[0];
        var myDoc = getXML(url);
        var xmlData = xmlToObject(myDoc.documentElement);
        console.log(xmlData)
        console.log(xmlData.sysData);
        trmbTop.sysData = xmlData.sysData;
        trmbTop.optionData = xmlData.options;
        var rxBrand = trmbTop.sysData.brand - 0;
        if (rxBrand > 10) rxBrand = 0;
        trmbTop.sysData.brand = rxBrand;
        trmbTop.rxBrand = rxBrand;
        switch (rxBrand) {
            case 1:
                trmbTop.omniBrand = 'Fugro';
                break;
            case 3:
                trmbTop.omniBrand = 'Starfix';
                break;
            case 4:
                trmbTop.omniBrand = 'Seastar';
                break;
            case 5:
                trmbTop.omniBrand = 'Marinestar';
                break;
            case 8:
                trmbTop.omniBrand = 'Bridge Mate';
                break;
            case 9:
                trmbTop.omniBrand = 'Olex';
                break;
            default:
                trmbTop.omniBrand = 'OmniSTAR';
                break;
        }
        switch (rxBrand) {
            case 1:
            case 3:
            case 4:
            case 5:
            case 8:
            case 9:
                trmbTop.isFugroBrand = true;
                break;
            default:
                trmbTop.isFugroBrand = false;
                break;
        }
        trmbTop.testMode = (trmbTop.sysData.testMode == "TRUE");
        trmbTop.simpleMenu = xmlData.options.simpleMenu == "TRUE" && !trmbTop.testMode;
        trmbTop.brightness = 'day';
        if (trmbTop.optionData.OptFugroWebUI == 'TRUE') {
            var distance = trmbTop.sysData.sunState.dist / 1000 - 10000;
            trmbTop.brightness = (distance > 666) ? 'night': (distance > 0) ? 'dusk': 'day';
        }
        if (trmbTop.sysData.RXName == "FASA+") {
            trmbTop.sysData.RXName = "\u0424\u0410\u0417\u0410+";
        }
    }
}
getSysData();
if (self === trmbTop) initializeLanguage();
function getOptionData(force) {
    if (!trmbTop.optionData || force) {
        trmbTop.optionData = xmlToObject(getDoc('xml/dynamic/options.xml')).options;
        trmbTop.testMode = (trmbTop.optionData.testMode == 'TRUE');
    }
    return trmbTop.optionData;
}
function getXmlAsync(url, successFunction, failFunction, getText) {
    if (self.jQuery == undefined) {
        alert('Need jquery.js for getXmlAsync');
        return;
    }
    jQuery.ajax(url, {
        complete: function(jqXHR, status) {
            if (status == 'success') {
                if (successFunction) successFunction(getText ? jqXHR.responseText: jqXHR.responseXML);
            } else if (failFunction) failFunction(jqXHR, status);
        },
        timeout: 10000
    });
}
function showGetXmlError(doc, contentDiv, warningDiv) {
    jQuery('#' + contentDiv).hide();
    jQuery('#' + warningDiv).html('<h1>' + getString('PageLoadError') + '</h1>' + 'XML -- ' + doc.status + ' : ' + doc.statusText).show();
}
function getXml(url) {
    if (self.jQuery == undefined) {
        alert('Need jquery.js for getXml');
        return;
    }
    var doc = jQuery.ajax(url, {
        async: false,
        timeout: 10000
    });
    if (doc.statusText == "OK") {
        if (trmbTop.hideCommFailure) trmbTop.hideCommFailure();
        return doc.responseXML;
    } else {
        if (trmbTop.showCommFailure) trmbTop.showCommFailure('<h2>' + getString('commFailure') + '</h2>' + '<br/>URL:' + url + '<br/>Returned ' + doc.status + ':' + doc.statusText);
        return null;
    }
}
function getXML(file) {
    var xmldoc = null;
    if (typeof XMLHttpRequest != 'undefined') {
        xmldoc = new XMLHttpRequest();
    } else if (typeof ActiveXObject != 'undefined') {
        try {
            xmldoc = new ActiveXObject('Microsoft.XMLHTTP');
        } catch(e) {}
    }
    if (xmldoc == null) {
        alert("Need XML javascript support!");
        return;
    }
    console.log(file);
    xmldoc.open("GET", file, false);
    xmldoc.send(null);
    return xmldoc.responseXML;
}
function getDocRoot(FileName) {
    var url = correctPath(FileName);
    if (url.substring(0, 1) != "/") {
        url = RootLocation + url;
    }
    var Doc = (self.jQuery ? getXml(url) : getXML(url));
    if (Doc) return Doc.documentElement;
    else return undefined;
}
function getDoc(FileName) {
    var url = correctPath(FileName);
    if (url.substring(0, 1) != "/") {
        url = RootLocation + url;
    }
    var Doc = getXML(url);
    return Doc;
}
function correctPath(FileName) {
    var current_root = document.location.pathname;
    if (FileName.indexOf("http") == 0 || FileName.indexOf("file:") == 0 || FileName.indexOf("CACHEDIR") >= 0 || current_root.indexOf("CACHEDIR") < 0) {
        newlink = FileName;
    } else {
        var pos = current_root.search(/CACHEDIR[0-9]*/);
        var pos2 = current_root.substring(pos).search("/");
        var newlink = current_root.slice(0, pos + pos2 + 1);
        if (FileName.indexOf("../") == 0) {
            FileName = FileName.substring(3);
        }
        newlink += FileName;
    }
    return (newlink);
}
function GetLangStrings(lang) {
    if (langLoaded != lang) {
        strings = GetStringRoot(lang);
        if (strings.lastChild.xml) {
            langStrings = strings.lastChild.xml;
        } else {
            langStrings = "<data>";
            for (i = 0; i < strings.lastChild.childNodes.length; i++) {
                langStrings += "<" + strings.lastChild.childNodes[i].nodeName + ">";
                myNode = strings.lastChild.childNodes[i].textContent;
                myNode = xreplace(myNode, "&", "&amp;");
                myNode = xreplace(myNode, 0x0d, "\n");
                myNode = xreplace(myNode, 0x0a, "\r");
                langStrings += myNode;
                langStrings += "</" + strings.lastChild.childNodes[i].nodeName + ">";
            }
            langStrings += "</data>";
        }
        langLoaded = lang;
    }
    return (langStrings);
}
function xreplace(checkMe, toberep, repwith) {
    var temp = checkMe;
    var i = temp.indexOf(toberep);
    while (i > -1) {
        temp = temp.replace(toberep, repwith);
        i = temp.indexOf(toberep, i + repwith.length + 1);
    }
    return temp;
}
function GetRxID() {
    return trmbTop.sysData.RXType;
}
function GetRxBrand() {
    return trmbTop.rxBrand;
}
function getBrandedOmniStarLabel(shortName) {
    switch (trmbTop.rxBrand) {
        case 1:
            return 'Fugro';
        case 3:
            return 'Starfix';
        case 4:
            return 'Seastar';
        case 5:
            return 'Marinestar';
        case 8:
            return 'Bridge Mate';
        case 9:
            return 'Olex';
        default:
            return shortName ? 'OMNI': 'OmniSTAR';
    }
}
function getBackgroundColor() {
    switch (GetRxBrand()) {
        case 0:
        case 10:
            return "#fff5e4";
        case 6:
            return "#fcf4e4";
        case 7:
            return "#ffffff";
        default:
            if (trmbTop.brightness == 'dusk') return '#000088';
            if (trmbTop.brightness == 'night') return '#000000';
            else return "#ffffff";
    }
}
function GetRxFamily() {
    return trmbTop.sysData.family;
}
function GetRxHardware() {
    return trmbTop.sysData.hardware;
}
function GetRxSerial() {
    return trmbTop.sysData.serial;
}
function GetRxName() {
    return trmbTop.sysData.RXName;
}
function GetRxOwner() {
    return trmbTop.sysData.ownerString1;
}
function getTagValue(orig, root, tagName) {
    var tmp = root.getElementsByTagName(tagName)[0];
    if (tmp && tmp.firstChild) {
        return tmp.firstChild.data;
    } else {
        return orig;
    }
}
function setTagValue(value, root, tagName) {
    var tmp = root.getElementsByTagName(tagName)[0];
    if (tmp && tmp.firstChild) {
        tmp.firstChild.data = value;
    }
}
function sendPostJSON(url, jsonbody) {
    var xmlhttp = null;
    if (typeof XMLHttpRequest != 'undefined') {
        xmlhttp = new XMLHttpRequest();
    } else if (typeof ActiveXObject != 'undefined') {
        try {
            xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
        } catch(e) {}
    }
    if (xmlhttp == null) {
        alert("Need XML javascript support!");
        return;
    }
    xmlhttp.open("POST", url, false);
    var boundary = "ThisIsASampleBoundary_" + Date.parse(new Date());
    xmlhttp.setRequestHeader("Content-Type", "multipart/mixed; boundary=" + boundary);
    var body;
    body = "--" + boundary + "\r\n";
    body += "Content-Type: text/plain\r\n";
    body += "Content-Disposition: inline\r\n";
    body += "Content-Description: text-json\r\n";
    body += "\r\n";
    body += jsonbody;
    body += "\r\n";
    body += "--" + boundary + "--\r\n";
    xmlhttp.send(body);
    return xmlhttp.responseXML;
}
function xmlToObject(node) {
    var obj = new Object();
    var attributeCount;
    if (node.attributes) attributeCount = node.attributes.length;
    else attributeCount = 0;
    var childrenCount = node.childNodes.length;
    if (childrenCount == 0 && attributeCount == 0 && arguments.length == 1) {
        return '';
    }
    for (var i = 0; i < attributeCount; ++i) {
        obj['__' + node.attributes[i].name] = node.attributes[i].value;
    }
    for (var i = 1; i < arguments.length; ++i) {
        obj[arguments[i]] = new Array();
    }
    for (var i = 0; i < childrenCount; ++i) {
        var child = node.childNodes[i];
        var name;
        var value;
        if (child.nodeType == 8) {
            continue;
        } else if (child.nodeType == 3) {
            if (childrenCount == 1 && attributeCount == 0) {
                return child.nodeValue;
            } else {
                name = '__str';
                value = child.nodeValue;
            }
        } else if (child.nodeType == 1) {
            name = node.childNodes[i].tagName;
            value = xmlToObject(child);
        } else {
            name = '__unknownNodeType';
            value = child.nodeType;
        }
        if (obj[name] == undefined) {
            obj[name] = value;
        } else if (obj[name] instanceof Array) {
            obj[name].push(value);
        } else {
            obj[name] = new Array(obj[name], value);
        }
    }
    if (obj.__str instanceof Array) {
        obj.__str = obj.__str.join('');
        var props = 0;
        for (var p in obj)++props;
        if (props == 1) return obj.__str;
    }
    return obj;
}
var languageAbbreviations = ['en', 'zh', 'fi', 'fr', 'de', 'it', 'ja', 'nl', 'no', 'pl', 'pt', 'ru', 'es', 'sv'];
var languageFlags = {
    en: "usFlag.gif",
    zh: "zhFlag.png",
    fi: "fiFlag.png",
    fr: "frFlag.png",
    de: "deFlag.png",
    it: "itFlag.png",
    ja: "jaFlag.png",
    nl: "nlFlag.png",
    no: "noFlag.png",
    pl: "plFlag.png",
    pt: "ptFlag.png",
    ru: "ruFlag.png",
    es: "esFlag.png",
    sv: "svFlag.png"
};
var languageNames = {
    en: 'English',
    zh: '\u7b80\u4f53\u4e2d\u6587',
    fi: 'Suomi',
    fr: 'Fran\u00E7ais',
    de: 'Deutsch',
    it: 'Italiano',
    ja: '\u65e5\u672c\u8a9e',
    nl: 'Nederlands',
    no: 'Norsk',
    pl: 'Polski',
    pt: 'Portugu\u00eas',
    ru: '\u0420\u0443\u0441\u0441\u043a\u0438\u0439',
    es: 'Espa\u00f1ol',
    sv: 'Svenska'
};
function setPageTitleAndHelp(titleToken, helpFile) {
    if (trmbTop.miniBrowser) return;
    var title;
    if (titleToken.charAt(0) != '\\') title = getString(titleToken, trmbTop.rxBrand);
    else title = titleToken.substring(1);
    var help = '';
    if (helpFile && trmbTop.sysData.family != 'INFRA' && (trmbTop.rxBrand == 0 || trmbTop.rxBrand == 10) && !trmbTop.simpleMenu) {
        help = '<a href="javascript:parent.doHelp(\'' + helpFile + '\');void 0;">' + '<img src="' + cacheDirPath('images/help.gif') + '" width="30px" ' + 'align="bottom" border="0"/>' + '</a>';
    }
    if (trmbTop.main && trmbTop.main.setPageTitle) trmbTop.main.setPageTitle(title + help);
    else toInnerHtml('header', '<nobr><h1>' + title + help + '</h1></nobr>');
}
function strip(s) {
    s = s.replace(/^\s*/, '');
    s = s.replace(/\s*$/, '');
    return s;
}
function stripTrailingSpace(s) {
    return s.replace(/\s*$/, '');
}
function isNotAnInteger(s) {
    return (s.match(/^\s*[+-]?\d+\s*$/) == null);
}
function isNotAFloat(s) {
    return (s.match(/^\s*[+-]?((\d+\.?\d*)|(\.?\d+))\s*$/) == null);
}
function isHexadecimal(s) {
    return (s.length > 0 && s.match(/[^0-9A-Fa-f]/) == null);
}
function loadDataFrame(url) {
    if (trmbTop.ldfTimer != undefined) trmbTop.main.clearTimeout(trmbTop.ldfTimer);
    clearTimeout(loadAfterDelayTimer); (new Cookie()).set('lastDataFrame', url);
    if (url.match(/^http:/) == null) url = cacheDirPath(url);
    if (trmbTop.main.setPageTitle) {
        trmbTop.main.setPageTitle('');
    } else {
        displayPageTitle(url);
    }
    var frames = trmbTop.main.frames;
    var dframe = frames[frames.length - 1];
    try {
        var d = dframe.document.documentElement;
        d = d.getElementsByTagName('body');
        if (d.length != 0) d[0].innerHTML = '';
    } catch(e) {
        dframe.location = 'about:blank';
    }
    dframe.location = url;
    try {
        dframe.name = 'dataFrame';
    } catch(e) {};
}
function loadDataFrameAfterDelay(url, delay) {
    if (delay == undefined) delay = 2000;
    if (trmbTop.ldfTimer != undefined) trmbTop.main.clearTimeout(trmbTop.ldfTimer);
    trmbTop.ldfTimer = trmbTop.main.setTimeout('loadDataFrame("' + url + '")', delay);
}
function submitFormWithTag(theForm, url, tag) {
    if (url == '') {
        url = theForm.action;
    }
    e = theForm.elements;
    s = '';
    separator = '?';
    for (i = 0; i < e.length; ++i) {
        s += e[i].type + '-' + e[i].name + '=' + e[i].value + '\n';
        if (e[i].type == 'text' || e[i].type == 'hidden' || e[i].type == 'password' || (e[i].type == 'radio' && e[i].checked) || (e[i].type == 'checkbox' && e[i].checked)) {
            url += separator + e[i].name + '=' + escape(e[i].value);
            separator = '&';
        } else if (e[i].type == 'radio' || e[i].type == 'button' || e[i].type == 'checkbox') {} else if (e[i].type == 'select-one') {
            if (e[i].selectedIndex >= 0) {
                p = e[i].options[e[i].selectedIndex].value;
                url += separator + e[i].name + '=' + escape(p);
                separator = '&';
            }
        } else {
            alert('submitForm: problem with ' + e[i].type + '=' + e[i].name);
            return;
        }
    }
    if (tag != '') url += '#' + tag;
    trmbTop.main.dataFrame.location = url;
}
function submitForm(theForm, url) {
    submitFormWithTag(theForm, url, '');
}
function showHelp(url, name) {
    name = name.replace("-", "_");
    w = window.open(url, name, "toolbar,resizable,scrollbars");
    w.focus();
}
loadAfterDelayTimer = setTimeout('', 1);
var loadAfterDelayDocument = null;
function loadAfterDelay(doc, url, msecs) {
    clearTimeout(loadAfterDelayTimer);
    oldurl = doc.location;
    loadAfterDelayDocument = doc;
    loadAfterDelayTimer = setTimeout('delayDone( "' + url + '","' + oldurl + '")', msecs);
}
function delayDone(newurl, oldurl) {
    if (loadAfterDelayDocument.location == oldurl) {
        loadAfterDelayDocument.location.replace(newurl);
    }
}
function getString(token) {
    if (token == undefined) return 'undef';
    if (token.charAt(0) == '\\') return token.substring(1);
    if (self.trmbTop && trmbTop.main && trmbTop.main != self && trmbTop.main.getString) return trmbTop.main.getString(token);
    var lang = trmbTop.language;
    var StringRoot = GetStringRoot(lang);

    var str = StringRoot.getElementsByTagName(token)[0];
    if (str && str.firstChild && str.firstChild.nodeValue) {
        var s = str.firstChild.nodeValue;
        s = s.replace(/\\n/g, '\n');
        s = s.replace(/OmniSTAR/, trmbTop.omniBrand);
        return s;
    }
    return "missing trans " + token;
}
function byteSymbol() {
    return (trmbTop.language != 'fr') ? 'B': 'o';
}
function monthAbbr(month) {
    if (trmbTop.language == 'en') {
        switch (month) {
            case 1:
                return 'Jan';
            case 2:
                return 'Feb';
            case 3:
                return 'Mar';
            case 4:
                return 'Apr';
            case 5:
                return 'May';
            case 6:
                return 'Jun';
            case 7:
                return 'Jul';
            case 8:
                return 'Aug';
            case 9:
                return 'Sep';
            case 10:
                return 'Oct';
            case 11:
                return 'Nov';
            case 12:
                return 'Dec';
        }
    }
    return month + '';
}
function checkRefCurPos(RefLat, RefLon, RefHgt, CurLat, CurLon, CurHgt) {
    var msg = null;
    var PI = 3.14159265358979323846;
    var RefLatDeg;
    var RefLonDeg;
    RefLatDeg = RefLat;
    RefLonDeg = RefLon;
    RefLat *= PI / 180;
    RefLon *= PI / 180;
    var a = 6378137;
    var f = 1 / 298.257223563;
    var e2 = 2 * f - f * f;
    var W = Math.sqrt(1 - e2 * Math.sin(RefLat) * Math.sin(RefLat));
    var N = a / W;
    var M = a * (1 - e2) / (W * W * W);
    var dlat = (CurLat * PI / 180.0) - RefLat;
    var dlon = (CurLon * PI / 180.0) - RefLon;
    var dhgt = CurHgt - RefHgt;
    var dN = M * dlat;
    var dE = N * Math.cos(RefLat) * dlon;
    var Range = Math.sqrt((dN * dN) + (dE * dE) + (dhgt * dhgt));
    if (Range > 100) {
        var metreAbbr = getString('MetreAbbr');
        msg = getString("refPosFar") + "\n";
        msg += getString("refPos") + "\n";
        msg += LatLon2DegMinSec(RefLatDeg, RefLonDeg);
        msg += " " + getString("hgt") + ": " + RefHgt.toFixed(3) + metreAbbr + "\n";
        msg += "\n\n" + getString("curPos") + "\n";
        msg += LatLon2DegMinSec(CurLat, CurLon);
        msg += " " + getString("hgt") + ": " + CurHgt.toFixed(3) + metreAbbr + "\n";
        msg += "\n\n\n" + getString("rangeDiff") + " " + Range.toFixed(0) + metreAbbr;
    }
    return msg;
}
function LatLon2DegMinSec(RefLat, RefLon) {
    var msg;
    if (RefLat > 0) {
        LatType = getString("NorthAbbr");
    } else {
        RefLat *= -1;
        LatType = getString("SouthAbbr");
    }
    LatDeg = Math.floor(RefLat);
    RefLat -= LatDeg;
    LatMin = Math.floor(RefLat * 60);
    RefLat -= LatMin / 60;
    LatSec = RefLat * 3600;
    msg = getString("lat") + ": " + LatDeg.toFixed(0) + "\260 ";
    msg += LatMin.toFixed(0) + "\' ";
    msg += LatSec.toFixed(5) + "\" ";
    msg += LatType + "\n";
    if (RefLon > 0) {
        LonType = getString("EastAbbr");
    } else {
        RefLon *= -1;
        LonType = getString("WestAbbr");
    }
    LonDeg = Math.floor(RefLon);
    RefLon -= LonDeg;
    LonMin = Math.floor(RefLon * 60);
    RefLon -= LonMin / 60;
    LonSec = RefLon * 3600;
    msg += getString("lon") + ": " + LonDeg.toFixed(0) + "\260 ";
    msg += LonMin.toFixed(0) + "\' ";
    msg += LonSec.toFixed(5) + "\" ";
    msg += LonType + "\n";
    return msg;
}
function ToUpper(s) {
    var upperS;
    upperS = s.toUpperCase(s);
    return upperS;
}
function ArrayContains(array, element) {
    var i = array.length;
    while (i--) {
        if (array[i] == element) {
            return true;
        }
    }
    return false;
}
function dojoRequires() {
    dojo.require("dojox.charting.Chart2D");
    switch (trmbTop.rxBrand) {
        case 1:
        case 2:
        case 3:
        case 4:
        case 5:
        case 7:
        case 8:
        case 9:
            dojo.require("dojox.charting.themes.fugro");
            break;
        case 6:
            dojo.require("dojox.charting.themes.ursus");
            break;
        default:
            dojo.require("dojox.charting.themes.trimble");
            break;
    }
}
function dojoSetTheme(chart) {
    switch (trmbTop.rxBrand) {
        case 1:
        case 2:
        case 3:
        case 4:
        case 5:
        case 7:
        case 8:
        case 9:
            chart.setTheme(dojox.charting.themes.fugro);
            break;
        case 6:
            chart.setTheme(dojox.charting.themes.ursus);
            break;
        default:
            chart.setTheme(dojox.charting.themes.trimble);
            break;
    }
}
function disableForm(cancelId) {
    var selection = jQuery(':input');
    if (cancelId != undefined) selection = selection.not('#' + cancelId);
    selection.attr('disabled', '1');
}
function disableFormIfNotAuthorized(cancelId) {
    if (trmbTop.sysData.SecSetConfig != '1' || (trmbTop.sysData.RXType == '243' && trmbTop.sysData.testMode == 'FALSE')) disableForm(cancelId);
}
function findPos(obj) {
    var curleft = 0;
    var curtop = 0;
    if (obj.offsetParent) {
        do {
            curleft += obj.offsetLeft;
            curtop += obj.offsetTop;
        } while ( obj = obj . offsetParent );
    }
    return [curleft, curtop];
}
function uploadFileFromForm(theForm, url, callbackFunction) {
    var iframe = jQuery('#uploadIframe');
    iframe.load(function() {
        var results = iframe.contents().find('body')[0].innerHTML;
        results = xmlToObject(jQuery.parseXML(results));
        if (results.ok) {
            results.OK = results.ok;
            delete results.ok;
        }
        if (results.fail) {
            results.FAIL = results.fail;
            delete results.fail;
        }
        iframe.off('load');
        if (callbackFunction) callbackFunction(results);
    });
    theForm.action = url;
    theForm.target = 'uploadIframe';
    theForm.submit();
}